﻿Public Class QuanLyBaoCaoThu

    Private str As String

    Private Sub btnXem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXem.Click
        Dim str As String = "select pt.Ngay , pt.SoTien, us.TenUser Nguoi, ng.TenNganHang TaiKhoan, tn.TenThuNhap PhanLoai, pt.ChiTiet" &
                            " from PhieuThu pt, [User] us, NganHang ng, ThuNhap tn" &
                            " where pt.MaUser = us.MaUser and pt.MaNganHang = ng.MaNganHang and pt.MaThuNhap = tn.MaThuNhap" '&
            '" order by pt.Ngay"


        

        If cboThang.Text = "" Or cboNam.Text = "" Then
            MessageBox.Show("Xin vui lòng chọn tháng năm")
            Return
        End If

        If cboThang.Text = "Tất cả" Then
            str = str & " and year(Ngay) = " & cboNam.Text
        Else
            str = str & " and year(Ngay) = " & cboNam.Text & " and month(Ngay) = " & cboThang.Text
        End If

        str = str & " order by Ngay"


        'Lay du lieu
        Dim dt As New DataTable
        dt = ProcFunc.ExecuteFuncSQL(str)

        Dim rpt = New rptBaoCaoThu 'Khoi tao 1 reoprt
        'Do du lieu len report va gan vao reportviewer
        rpt.SetDataSource(dt)
        rptXem.ReportSource = rpt

    End Sub

End Class